/**
 * 运营管理编辑员工
 */
import './index.less'
import tem from './index.html'
import $_fn from '~plugins'
class newpasswordCtrl {
  constructor($scope,$rootScope,http,$ui) {
  	  console.log($scope.params)
      $scope.cancel = function () {
          $rootScope.$uiDirectiveModal.close() //关闭方法
      }
     $scope.param1={
    	username:JSON.parse($scope.params).username,
    	real_name:JSON.parse($scope.params).real_name,
    	id:JSON.parse($scope.params).id
    }
    $scope.param2={}
  	//添加管理员提交
  	  $scope.tiJiao1=function(){
	  	  	$scope.param2.id=$scope.param1.id;
	  	  	if(!$scope.param2.password){
	  	  		$ui.toast({
					text:'请输入密码',
					type:'warning',
					appendTo:'.newpassword'
				})
	  	  		return 
	  	  	}
  	  		http.post('updateUserPassword.do',$scope.param2,function (data) {
				if(data.errcode==1){
					$ui.toast({
						text:data.errmsg,
						type:'succeed'
					})
			       // window.history.go(0)
				}else{
					$ui.toast({
						text:data.errmsg,
						type:'warning',
						appendTo:'.newpassword'
					})
				}
	        },function(_data){
	            console.log(_data);//报错
	      	})
  	  }
  }
}
newpasswordCtrl.$inject = ['$scope','$rootScope','http','$ui']
module.exports = angular.module('directive.newpassword', []).directive('newpassword', function() {
    return {
        template: tem,
        replace:true,
        controller: newpasswordCtrl,
        scope:{
        	params:"@"
        }
    }
}).name